--[[
  拓展包名称：μ（四班杀μ势力角色）
  说明：目前暂时没制作势力，就用魏蜀吴分别对应四班杀里的蓝红绿势力。
  作者：st
  武将数目：μ势力总共23名武将
  武将列表：
    刘璐瑶（liuluyao）
    ...
  尚需完善的内容：好多好多……but, that's a good start!
  备注：
    任重道远
--]]

-- 四班杀的武将作为大拓展包开发，μ势力作为其中一个子拓展包
local extension = Package:new("miu")
extension.extensionName = "siban"

Fk:loadTranslationTable{
    ["siban"] = "四班",
    ["miu"] = "μ",
}

-- 刘璐瑶
local liuluyao = General:new(extension, "liuluyao", "wu", 3, 3, General.female)
-- 技能1【指挥】：你可将梅花牌当借刀杀人。
local zhihui = fk.CreateViewAsSkill{
    name = "zhihui",
    anim_type = "control",
    pattern = "collateral",
    card_filter = function(self, to_select, selected)
      if #selected == 1 then return false end
      return Fk:getCardById(to_select).suit == Card.Club
    end,
    view_as = function(self, cards)
      if #cards ~= 1 then
        return nil
      end
      local c = Fk:cloneCard("collateral")
      c.skillName = self.name
      c:addSubcard(cards[1])
      return c
    end,
    enabled_at_response = function (self, player, response)
      return not response
    end
}
-- 技能2【排练】：当一名角色失去武器牌时，你可令其摸2张牌。
local pailian = fk.CreateTriggerSkill{
  name = "pailian",
  anim_type = "drawcard",
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    -- 检查是否有角色失去武器牌
    for _, move in ipairs(data) do
      if move.from == target.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip and Fk:getCardById(info.card).sub_type == Card.SubtypeWeapon then
            return true
          end
        end
      end
    end
    return false
  end,
  on_trigger = function(self, event, target, player, data)
    -- 找到失去武器牌的角色
    local targetPlayer = nil
    for _, move in ipairs(data) do
      if move.from == target.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip and Fk:getCardById(info.card).sub_type == Card.SubtypeWeapon then
            targetPlayer = room:getPlayerById(move.from)
            break
          end
        end
      end
    end
    self.cancel_cost = false
    if targetPlayer then
      self:doCost(event, target, player, data)
    end
  end,
  on_cost = function(self, event, target, player, data)
    -- 询问玩家是否发动技能
    local toChoose = {targetPlayer} -- 将失去武器牌的角色作为可选择的目标
    local chosen = player.room:askForChoosePlayers(player, toChoose, 1, 1, "是否发动排练技能？", self.name, true)
    if #chosen > 0 then
      self.cost_data = {tos = chosen}
      return true
    end
    self.cancel_cost = true
  end,
  on_use = function(self, event, target, player, data)
    -- 令选择的角色摸两张牌
    local targetPlayer = room:getPlayerById(self.cost_data.tos[1])
    targetPlayer:drawCards(2, self.name)
  end
}
liuluyao:addSkill(zhihui)
liuluyao:addSkill(pailian)

Fk:loadTranslationTable{
    ["liuluyao"] = "刘璐瑶",
    ["#liuluyao"] = "虫子",
    ["designer:liuluyao"] = "大脸",
    ["cv:liuluyao"] = "配音演员",
    ["illustrator:liuluyao"] = "画师",
    ["zhihui"] = "指挥",
    [":zhihui"] = "你可将梅花牌当借刀杀人",
    ["pailian"] = "排练",
    [":pailian"] = "当一名角色失去武器牌时，你可令其摸两张牌",
}



return extension